﻿using PlatypusPlanner.Components.Database;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlatypusPlanner.Components.Base
{
    public abstract class BaseController
    {
        public PlatypusEntities Context = null;
        public BaseController(PlatypusEntities context = null)
        {
            if (context != null)
                Context = context;
            else
                Context = EntityContextController.GetContext();
        }

        #region common functions

        public void Delete(object obj)
        {
            Context.DeleteObject(obj);
        }
        public void DeleteObjects(IEnumerable entityCollection)
        {
            foreach (var entity in entityCollection)
                this.Context.DeleteObject(entity);
        }
        public void SaveChanges()
        {
            this.Context.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);
        }

        #endregion

        #region query helpers



        #endregion
    }
}
